/** @format */

import { CCInteger, _decorator } from "cc";
import { app } from "../../FrameWork/App";
import { BaseAdBtn } from "../Component/BaseAdBtn";
import { mEventConst } from "../Const/EventConst";
const { ccclass, property } = _decorator;

@ccclass("AdUnlockRole")
export class AdUnlockRole extends BaseAdBtn {
    @property(CCInteger)
    roleType: number = 0;

    protected init(): void {
        if ("1" == localStorage.getItem("role" + this.roleType)) {
            this.node.destroy();
            return;
        }
        super.init();
    }

    protected onAdSucc(): void {
        localStorage.setItem("role" + this.roleType, "1");
        this.node.destroy();
        app.eventMgr.dispatch(mEventConst.UPDATE_ROLE_SELECT);
    }
}
